Skip to content

Conversation

@ppotapov-aws
Copy link
Collaborator

@ppotapov-aws ppotapov-aws commented Jan 15, 2026

We need to lower BIR AP properly since vector offset now is an Access it has to be lowered as well.
Sample kernel:

def kernel():
  a = nl.ndarray((32, 32), nl.int8)
  b = nl.ndarray((32, 32), nl.int8)
  c = nl.ndarray((32, 32), nl.int8)
  nisa.dma_copy(a, b.ap([[32, 1], [1,1]], vector_offset=c.ap([[2,2]])))

Output copy component for b in KLR

src := KLR.Core.TensorRef.abstract
         (KLR.Core.Access.birPattern
           { tensor := { name := "b.3",
                         dtype := KLR.Core.Dtype.int8,
                         shape := { parDim := 32, freeDims := [32] },
                         address := { name := "b.3",
                                      memory := KLR.Core.Memory.sbuf,
                                      parSize := 32,
                                      freeSize := 32,
                                      parOffset := none,
                                      freeOffset := none,
                                      isShared := false },
                         freeElements := 32,
                         parWF := _,
                         freeWF := _,
                         addressRotation := false },
             offset := 0,
             pattern := [{ step := 32, num := 1, offset := 0 },
                         { step := 1, num := 1, offset := 0 }],
             scalarOffset := none,
             vectorOffset := some (KLR.Core.Access.birPattern
                               { tensor := { name := "c.4",
                                             dtype := KLR.Core.Dtype.int8,
                                             shape := { parDim := 32,
                                                        freeDims := [32] },
                                             address := { name := "c.4",
                                                          memory := KLR.Core.Memory.sbuf,
                                                          parSize := 32,
                                                          freeSize := 32,
                                                          parOffset := none,
                                                          freeOffset := none,
                                                          isShared := false },
                                             freeElements := 32,
                                             parWF := _,
                                             freeWF := _,
                                             addressRotation := false },
                                 offset := 66,
                                 pattern := [{ step := 32, num := 1, offset := 2 },
                                             { step := 1, num := 1, offset := 2 }],
                                 scalarOffset := none,
                                 vectorOffset := none,
                                 indirectDim := 0,
                                 dtypeOverride := none }),
                                              indirectDim := 0,
                                              dtypeOverride := none }),
                                 compute_op := KLR.Core.DgeComputeOp.none,
                                 oobMode := KLR.Core.DmaBounds.error,
                                 dgeMode := 0,
                                 uniqueIndices := false,
                                 engine := KLR.Core.Engine.unassigned })

@yongweiy
Copy link
Collaborator

Can you explain what's c[[2,2]]?

@ppotapov-aws
Copy link
Collaborator Author

ppotapov-aws commented Jan 15, 2026

Can you explain what's c[[2,2]]?

Just something to make it look like a vector offset. Ah, I forgot to add .ap([[2,2]]). Should be copy pasting and not typing by hand. Fixed the description

@ppotapov-aws ppotapov-aws merged commit b348060 into main Jan 15, 2026
6 checks passed
@ppotapov-aws ppotapov-aws deleted the ppotapov/lower_bir_ap branch January 15, 2026 18:20
@ppotapov-aws ppotapov-aws restored the ppotapov/lower_bir_ap branch January 20, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants